/*
 @Date: 2022/4/24
 @Desc: 个人页面 页头
 */

import UIKit
import SnapKit

class IPMineHeaderView: UITableViewHeaderFooterView {

    static let reuseId = "mine_header_view"
    
    private lazy var mBgIV = UIImageView()
    private lazy var mVipStatusBt = UIButton()
    private lazy var mVipDescLabel = UILabel()
    
    override init(reuseIdentifier: String?) {
        super.init(reuseIdentifier: reuseIdentifier)
        initUI()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        initUI()
    }
    
    private func initUI(){
        let subs: [UIView] = [mBgIV,
                              mVipStatusBt,
                              mVipDescLabel]
        subs.forEach { it in
            it.translatesAutoresizingMaskIntoConstraints = false
            contentView.addSubview(it)
        }
        
        mBgIV.image = UIImage.init(named: "mine_vip_bg")
        mBgIV.snp.makeConstraints { make in
            make.bottom.top.equalToSuperview()
            make.left.equalToSuperview().offset(10)
            make.right.equalToSuperview().offset(-10)
        }
        
        let dict: [NSAttributedString.Key: Any] = [.font: UIFont.systemFont(ofSize: 14),
                                                  .foregroundColor: UIColor.white]
        let att = NSAttributedString.init(string: "未开通", attributes: dict)
        mVipStatusBt.setAttributedTitle(att, for: .normal)
        mVipStatusBt.layer.cornerRadius = 5
        mVipStatusBt.backgroundColor = UIColor.ip_vip_bt_bgcolor
        mVipStatusBt.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalTo(self.mBgIV.snp.right).offset(-20)
            make.size.equalTo(CGSize.init(width: 60, height: 30))
        }
        
        mVipDescLabel.textColor = UIColor.white
        mVipDescLabel.numberOfLines = 0
        mVipDescLabel.text = "你好\n嗯啊"
        mVipDescLabel.snp.makeConstraints { make in
            make.left.equalTo(self.mBgIV.snp.left).offset(20)
            make.centerY.equalToSuperview()
        }
    }
    
    
}
